#include<iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int num[n] = {};
    for(int i = 0;i<n;i++)
    {
        cin >> num[i];
    }
    int count = 0;
    for(int j = 0;j<n;j++)
    {
        int gewei = num[j]%10;
        int shiwei = (num[j]/10)%10;
        int baiwei = (num[j]/100)%10;
        int qianwei = (num[j]/1000);
        if(gewei-(shiwei+baiwei+qianwei)>0)
        {
            count++;
        }
        else
        {
            continue;
        }
    }
    cout << count << endl;
    return 0;
}